<?php
class  Lib
{

    /**
     * @desc this method will return all of day for month
     * @param void
     * @return array
     */  
    public static  function getDays()
    {
       $arrDay = array();
       for($i=1;$i<=31;$i++)
            $arrDay[$i]=$i;   
       return $arrDay; 
    } // end function 
    
    /**
     * @desc this method will return all of day for month
     * @param void
     * @return array
     */  
    public static  function getMonths()
    {
       
       $months = array();
       for($i=1;$i<=12;$i++)
            $months[]= array("value"=>$i,"text"=>strtolower(date("F",mktime(0,0,0,$i,1,2008))));  
       return $months; 
    } // end function 
    
    /**
     * @desc this method will return all year
     * @param void
     * @return array
     */  
    public static  function getYear()
    {
       
       $years = array();
       $current_year = date("Y");
       for($i=$current_year;$i>=1960;$i--)
            $years[]= $i;  
       return $years; 
    } // end function
    
    /**
     * @desc this method will return all country name in the worlds
     * @param void
     * @return array
     */  
    public static  function getCountries()
    {
       $country_list = array(
        "Afghanistan",
        "Albania",
        "Algeria",
        "Andorra",
        "Angola",
        "Antigua and Barbuda",
        "Argentina",
        "Armenia",
        "Australia",
        "Austria",
        "Azerbaijan",
        "Bahamas",
        "Bahrain",
        "Bangladesh",
        "Barbados",
        "Belarus",
        "Belgium",
        "Belize",
        "Benin",
        "Bhutan",
        "Bolivia",
        "Bosnia and Herzegovina",
        "Botswana",
        "Brazil",
        "Brunei",
        "Bulgaria",
        "Burkina Faso",
        "Burundi",
        "Cambodia",
        "Cameroon",
        "Canada",
        "Cape Verde",
        "Central African Republic",
        "Chad",
        "Chile",
        "China",
        "Colombi",
        "Comoros",
        "Congo (Brazzaville)",
        "Congo",
        "Costa Rica",
        "Cote d'Ivoire",
        "Croatia",
        "Cuba",
        "Cyprus",
        "Czech Republic",
        "Denmark",
        "Djibouti",
        "Dominica",
        "Dominican Republic",
        "East Timor (Timor Timur)",
        "Ecuador",
        "Egypt",
        "El Salvador",
        "Equatorial Guinea",
        "Eritrea",
        "Estonia",
        "Ethiopia",
        "Fiji",
        "Finland",
        "France",
        "Gabon",
        "Gambia, The",
        "Georgia",
        "Germany",
        "Ghana",
        "Greece",
        "Grenada",
        "Guatemala",
        "Guinea",
        "Guinea-Bissau",
        "Guyana",
        "Haiti",
        "Honduras",
        "Hungary",
        "Iceland",
        "India",
        "Indonesia",
        "Iran",
        "Iraq",
        "Ireland",
        "Israel",
        "Italy",
        "Jamaica",
        "Japan",
        "Jordan",
        "Kazakhstan",
        "Kenya",
        "Kiribati",
        "Korea, North",
        "Korea, South",
        "Kuwait",
        "Kyrgyzstan",
        "Laos",
        "Latvia",
        "Lebanon",
        "Lesotho",
        "Liberia",
        "Libya",
        "Liechtenstein",
        "Lithuania",
        "Luxembourg",
        "Macedonia",
        "Madagascar",
        "Malawi",
        "Malaysia",
        "Maldives",
        "Mali",
        "Malta",
        "Marshall Islands",
        "Mauritania",
        "Mauritius",
        "Mexico",
        "Micronesia",
        "Moldova",
        "Monaco",
        "Mongolia",
        "Morocco",
        "Mozambique",
        "Myanmar",
        "Namibia",
        "Nauru",
        "Nepa",
        "Netherlands",
        "New Zealand",
        "Nicaragua",
        "Niger",
        "Nigeria",
        "Norway",
        "Oman",
        "Pakistan",
        "Palau",
        "Panama",
        "Papua New Guinea",
        "Paraguay",
        "Peru",
        "Philippines",
        "Poland",
        "Portugal",
        "Qatar",
        "Romania",
        "Russia",
        "Rwanda",
        "Saint Kitts and Nevis",
        "Saint Lucia",
        "Saint Vincent",
        "Samoa",
        "San Marino",
        "Sao Tome and Principe",
        "Saudi Arabia",
        "Senegal",
        "Serbia and Montenegro",
        "Seychelles",
        "Sierra Leone",
        "Singapore",
        "Slovakia",
        "Slovenia",
        "Solomon Islands",
        "Somalia",
        "South Africa",
        "Spain",
        "Sri Lanka",
        "Sudan",
        "Suriname",
        "Swaziland",
        "Sweden",
        "Switzerland",
        "Syria",
        "Taiwan",
        "Tajikistan",
        "Tanzania",
        "Thailand",
        "Togo",
        "Tonga",
        "Trinidad and Tobago",
        "Tunisia",
        "Turkey",
        "Turkmenistan",
        "Tuvalu",
        "Uganda",
        "Ukraine",
        "United Arab Emirates",
        "United Kingdom",
        "United States",
        "Uruguay",
        "Uzbekistan",
        "Vanuatu",
        "Vatican City",
        "Venezuela",
        "Vietnam",
        "Yemen",
        "Zambia",
        "Zimbabwe"
    );
        
       return $country_list; 
    } // end function
    
    /**
     * @desc this method will show set of the value of object
     * @param object $obj
     * @return void
     */  
    public static  function pr($obj)
    {
        echo "<pre>";
        print_r($obj);
        echo "<pre>";
        
    } // end function 
    
    /**
     * @desc this method will show set of the value of object and then exit
     * @param object $obj
     * @return void
     */
    public static  function pre($obj)
    {
      Lib::pr($obj);
      exit;
    }  // end function 
    
    /**
     * @desc this method will encrypt data
     * @param string : $string data
     * @param string : $key is key     
     * @return void
     */
    function encrypt($string, $key) {
        $result = '';
        for($i=0; $i<strlen($string); $i++) {
            $char = substr($string, $i, 1);
            $keychar = substr($key, ($i % strlen($key))-1, 1);
            $char = chr(ord($char)+ord($keychar));
            $result.=$char;
        }
        return base64_encode($result);
    }// end function

     /**
     * @desc this method will decrypt data
     * @param string : $string data
     * @param string : $key is key     
     * @return void
     */
    function decrypt($string, $key) {
        $result = '';
        $string = base64_decode($string);

        for($i=0; $i<strlen($string); $i++) {
            $char = substr($string, $i, 1);
            $keychar = substr($key, ($i % strlen($key))-1, 1);
            $char = chr(ord($char)-ord($keychar));
            $result.=$char;
        }
        return $result;
    }// end function
     /**
    * @desc  function will save log to file
    * @param  
    */
    public static function saveLog($filename,$message)
    {
        $fp = fopen($filename,"a");
        if(!$fp)
            return false;
        fwrite($fp,$message);
        fclose($fp);
        return true;
    }
	
	
    static function genPass($num = 10)
    {
        $str = 'abcdefghijklmnopqrtuwxyzABCDEFGHIJKLMNOPQRTUWXYZ1234567890!@#$%^&*';
        $pass = "";
        for($i=0;$i<$num;$i++)
        {
            $index = rand(0,strlen($str)-1);
            $pass.= $str{$index};
        }
        return $pass;
        
    }
}
?>
